import axios from 'axios'

const instance = axios.create({
  // baseURL: 'https://www.zhipin.com',
  timeout: 10 * 1000
})

instance.interceptors.request.use(
  config => {
    // config.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
    return config
  },
  err => {
    console.log(err)
  }
)

instance.interceptors.response.use(
  res => {
    if (res.data.code !== 0) {
      throw new Error(res.data.message)
    }
    return res.data
  },
  err => {
    return Promise.reject(err)
  }
)

export default instance